package com.item.yxlottery.yxlottery.views;

/*
 *------------------------------
 * @创建者      Administrator
 * @创建时间    2016/12/19 19:52
 * @文件描述    
 *------------------------------
 */

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.akexorcist.roundcornerprogressbar.RoundCornerProgressBar;
import com.flyco.dialog.widget.NormalDialog;
import com.item.yxlottery.yxlottery.R;

import java.text.DecimalFormat;
import java.text.NumberFormat;

public class ApkLoadingDialog extends NormalDialog {


    private final View mView;
    private final TextView mTVProgress;
    private final RoundCornerProgressBar mRpbBar;

    public ApkLoadingDialog(Context context) {
        super(context);
        mView = View.inflate(mContext, R.layout.layout_apkloadingdialog, null);
        mTVProgress = (TextView) mView.findViewById(R.id.tv_apkloadingdialog_progress);
        mRpbBar = (RoundCornerProgressBar) mView.findViewById(R.id.rpb_apkloadingdialog_bar);
        setProgress(1f);
    }

    /*- 设置ProgressBar当前的进度 -*/
    public void setProgress(float progress) {
        mRpbBar.setProgress(progress);
    }

    /*- 设置ProgressBar的最大值 -*/
    public void setMaxProgress(float max) {
        mRpbBar.setMax(max);
    }

    /*- 设置显示的进度百分比 -*/
    public void setProgressPercentage(float max, float progress) {
        NumberFormat formatter = new DecimalFormat("0.0");
        mTVProgress.setText(formatter.format(new Double(progress / max)) + " %");
    }

    /*- 设置显示的进度百分比 -*/
    public void setProgressPercentage(String percentage) {
        mTVProgress.setText(percentage);
    }

    @Override
    public View onCreateView() {
        widthScale(.85f);
        return mView;
    }

    @Override
    public void setUiBeforShow() {

    }
}
